import Vue from 'vue'
import Router from 'vue-router'
import epidemicFKEntery from './epidemicFKEntery' // 职业危害因素监
import epidemicRouter from './epidemicRouter' // 导入疫情管理消毒、访客路由文件
import epidemicTrace from './epidemicTrace' // 导入疫情追溯、疫情上报
import thermometry from './thermometry' // 导入体温测量 体温异常
let router = [
    {
        path: '/',
        redirect: {
            name: 'IndexManager'
        }
    },
    {
        path: '/Index',
        name: 'Index',
        component: (resolve) => require(['@/components/Index'], resolve),
        children: [{
            path: '/',
            redirect: {
                name: 'IndexManager'
            }
        },
        {
            path: 'IndexManager',
            name: 'IndexManager',
            component: (resolve) => require(['@/components/IndexManager'], resolve),
            meta: {
                title: '首页'
            }
        },
        {
            path: 'newEdit',
            name: 'newEdit',
            component: (resolve) => require(['@/components/newEdit'], resolve),
            meta: {
                title: '工作台'
            }
        },
        {
            path: 'userinfo',
            name: 'userinfo',
            component: (resolve) => require(['@/components/userinfo'], resolve),
            meta: {
                title: '个人中心'
            }
        },
        {
            path: '/contact', // 个人中心联系客服
            name: 'contact',
            component: (resolve) => require(['@/components/contact'], resolve),
            meta: {
                title: '联系客服'
            }
        }
        ]
    }
]
let routes = new Set([...epidemicFKEntery, ...epidemicRouter, ...epidemicTrace, ...thermometry, ...router])
Vue.use(Router)
let newRouter = new Router({
    routes
    // base: '/history',
    // mode: 'history'
})
newRouter.beforeEach((to, from, next) => {
    // let userInfo = localStorage.getItem('userInfo') // 为登录
    // let loginInfo = localStorage.getItem('loginInfo') // 为登录
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

export default newRouter
